|
|
|
|
|
|
|
Figure 10.13.
Displaying the entry names in the TreeView. |
|
|
|
|
|
|
|
|
LISTING 10.9. ADDRDAO2.TXTADDING THE TREEVIEW CONTROL DATA INITIALIZATION CODE AS A ROUTINE CALLED FROM THEForm_LoadEVENT. |
|
|
|
 |
|
|
|
|
1: Private Sub Form_Load()
2: Set MyDb = OpenDatabase(App.Path & .mdb)
3: Call Set_NewTree
4: Call Set_TreeNodes
5: End Sub
6:
7: Public Sub Set_TreeNodes()
8: Dim Node_Key As String
9: Dim Entry_Letter As String * 1
10: Dim Node_Name As String
11: Set MyDyn = MyDb.OpenRecordset(Select * From [Address Entry], _
12: dbOpenDynaset)
13: If Not MyDyn.EOF And Not MyDyn.BOF Then
14: MyDyn.MoveFirst
15: Do Until MyDyn.EOF
16: Node_Key = CStr(MyDyn.Fields(0)) & ! & _
MyDyn.Fields(LastName)
17: Entry_Letter = Mid(MyDyn.Fields(LastName), 1, 1)
18: Node_Name = MyDyn.Fields(LastName) & , & _
19: MyDyn.Fields(FirstName)
20: Set MyNode = tvTreeView.Nodes.Add(Entry_Letter, tvwChild, _
21: Node_Key, Node_Name, 3)
22: MyDyn.MoveNext
23: Loop
24: End If
25: MyDyn.Close
26: End Sub |
|
|
|
|
|
|
|
|
Tip If you plan to use a Connection object in several different sections of the application code, open the connection once in the Form_Load routine and use the same connection object everywhere in the application. |
|
|
|
|
|
|